import hashlib
import os


def get_file_md5(file_path):
    with open(file_path, "rb") as f:
        m = hashlib.md5()
        bytes = f.read(1024)
        while (bytes != b''):
            m.update(bytes)
            bytes = f.read(1024)
        f.seek(0)
        return m.hexdigest()


def get_str_md5(text):
    m = hashlib.md5()
    m.update(text.encode("utf8"))
    return m.hexdigest()


def check_path(file_path):
    if not os.path.exists(file_path):
        os.makedirs(file_path)
